package channalType

type ChannalType int

// 10.IM 20.Push 30.短信 40.Email 50.公众号 60.小程序 70.企业微信
const (
	IM               ChannalType = 10 //IM消息
	Push             ChannalType = 20 //个推
	Sms              ChannalType = 30 //短信
	Email            ChannalType = 40 // 邮件
	EnterpriseWeChat ChannalType = 50 //企业微信
)

var ChannelMap = map[int]string{
	10: "IM",
	20: "Push",
	30: "Sms",
	40: "Email",
	50: "EnterpriseWeChat",
}

// 重写string方法，实现stringer接口
func (c ChannalType) String() string {
	switch c {
	case Sms:
		return "Sms"
	case Email:
		return "Email"
	case IM:
		return "IM"
	case Push:
		return "Push"
	case EnterpriseWeChat:
		return "EnterpriseWeChat"
	default:
		return "Unknown"
	}
}

// 编写Index方法,返回int枚举项的索引值
func (c ChannalType) Index() int {
	return int(c)
}

// Values 返回所有枚举项
func Values() []ChannalType {
	return []ChannalType{Sms, Email, IM, Push, EnterpriseWeChat}
}

// ExitOf 判断是否在枚举项中
func ExitOf(c ChannalType) bool {
	for _, v := range Values() {
		if v == c {
			return true
		}
	}
	return false
}
